package com.cskaoyan.controller;

import com.cskaoyan.module.bean.BaseRespVo;
import com.cskaoyan.module.bean.vo.MallIssueVO;
import com.cskaoyan.module.bo.AfterIssueBO;
import com.cskaoyan.module.bo.AfterIssueCreateBO;
import com.cskaoyan.module.pojo.MarketIssue;
import com.cskaoyan.service.MallIssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :ligenghuisheng
 * @Description:
 * @Date :2022/4/7  20:34
 */
@RestController
@RequestMapping("admin/issue")
public class MallIssueController {

    @Autowired
    MallIssueService mallIssueService;
    //展示问题首页
    @RequestMapping("list")
    public BaseRespVo showIssueList(AfterIssueBO afterIssueBO, MarketIssue marketIssue){
        MallIssueVO mallIssueVO = mallIssueService.list(afterIssueBO,marketIssue);

        return BaseRespVo.ok(mallIssueVO);
    }
    //新增问题
    @PostMapping("create")
    public BaseRespVo createIssue(@RequestBody AfterIssueCreateBO afterIssueCreateBO){
        MarketIssue marketIssue = mallIssueService.create(afterIssueCreateBO);

        return BaseRespVo.ok(marketIssue);
    }
    //编辑问题
    @PostMapping("update")
    public BaseRespVo updateIssue(@RequestBody MarketIssue marketIssue){
        MarketIssue marketIssue1 = mallIssueService.update(marketIssue);

        return BaseRespVo.ok(marketIssue1);
    }
    //删除问题
    @PostMapping("delete")
    public BaseRespVo deleteIssue(@RequestBody MarketIssue marketIssue){
         mallIssueService.delete(marketIssue);
        return BaseRespVo.ok("成功");

    }
}
